<!-- isELIgnored=true禁用EL表达式 -->
<%@ page isELIgnored="false" %>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!-- JSTL格式化标签 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/index.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/indexstyle.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
</head>
<body id="list-cont">

<div align="left" style="width: 100%;">
    <form action="main2">
        <input type="hidden" value="${goods.gName}" id="gName">
        <input type="hidden" value="${goods.sId}" id="sId">
    </form>
    <c:forEach items="${list}" var="info">
        <tr>
            <a onclick="detials(${info.id})" target="_self">
                <div class="layui-panel layui-inline push_goods")>

                    <div style="width: 200px; height: 200px ">
                        <img src="${info.imgUrl}" width="100%">
                    </div>

                    <div style="margin: 10px; width: 200px;">
                        <div class="layui-inline" align="left" style="height: 40px">
                        <span class="layui-font-14 layui-font-black" style="overflow: hidden;
                                     text-overflow:ellipsis;
                                     display:-webkit-box;
                                     -webkit-box-orient:vertical;
                                     -webkit-line-clamp:2;">
                                ${info.gName}
                        </span>
                        </div>
                        <div style="margin-top: 0px; font-weight: bold; color: red; font-size: 20px">
                            ￥<span>${info.gPrice}</span>
                        </div>
                        <p style="margin-top: 10px; font-weight: bold; color: #000000;">
                            <c:if test="${info.gCount == 0}">
                                暂时缺货
                            </c:if>
                            <c:if test="${info.gCount != 0}">
                                库存<span>${info.gCount}</span>
                            </c:if>
                        </p>
                    </div>
                </div>
            </a>
        </tr>
    </c:forEach>
    <br/>

    <div style="text-align: center;">
        <button class="layui-btn layui-btn-sm layui-btn-primary" onclick="queryByPageNO(1,${totalPage})">首页</button>
        <button class="layui-btn" onclick = "queryByPageNO(${pageNo-1},${totalPage})">上一页</button>
        <span class = "layui-font-16">${pageNo} / ${totalPage}页</span>
        <button class="layui-btn" onclick = "queryByPageNO(${pageNo+1},${totalPage})">下一页</button>
        <button class="layui-btn layui-btn-sm layui-btn-primary" onclick="queryByPageNO(${totalPage},${totalPage})">尾页</button>
    </div>
</div>

</body>
<script>
    function detials(id){
        if (${sessionScope.u.id == null}){
            <%--window.open("${pageContext.request.contextPath}/user/login","_black");--%>
           window.parent.location.href = "${pageContext.request.contextPath}/user/login";
        }else {
            window.open("${pageContext.request.contextPath}/shop/goods/GoodsGetails?id="+id,"_black")
        }

    }
    // 分页
    function queryByPageNO(pageNo,totalPage) {
        if (pageNo>=totalPage) pageNo=totalPage;
        var gName = $("#gName").val();
        var sId = $("#sId").val();
        var params = $("form").serialize();
        params+="&pageNo="+pageNo+"&gName="+gName+"&sId="+sId;
        // params = params+"&pageNo="+pageNo;
        console.info(gName);
        console.info(params);
        // var params = "pageNo="+pageNo;
        window.location.href="${pageContext.request.contextPath}/shop/goods/queryAllGoods?"+params;
    }
</script>
</html>
